<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"www.lixiaofei.cn","root":"/","scheme":"Mist","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":true,"storage":true,"lazyload":true,"nav":{"valine":{"order":-1}}},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="有网友提了一个问题：如何用 Python 实现输入 1~12，返回对应的英文月份简写。 看似简单的一个问题，其中却隐含了关于与用户交互的深层逻辑： 如何更友好？如何更健壮？ 那么一起看看如何做到吧。">
<meta property="og:type" content="article">
<meta property="og:title" content="一道小小 Python 编程题，体会编程之美">
<meta property="og:url" content="http://www.lixiaofei.cn/2021-11-15-input/index.html">
<meta property="og:site_name" content="管窥程序">
<meta property="og:description" content="有网友提了一个问题：如何用 Python 实现输入 1~12，返回对应的英文月份简写。 看似简单的一个问题，其中却隐含了关于与用户交互的深层逻辑： 如何更友好？如何更健壮？ 那么一起看看如何做到吧。">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-11-15T15:13:46.000Z">
<meta property="article:modified_time" content="2021-11-15T15:40:06.441Z">
<meta property="article:author" content="太阳雪">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://www.lixiaofei.cn/2021-11-15-input/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>一道小小 Python 编程题，体会编程之美 | 管窥程序</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">管窥程序</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Today is a gift</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

  <a href="https://github.com/alisx" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://www.lixiaofei.cn/2021-11-15-input/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="太阳雪">
      <meta itemprop="description" content="总结 技术 思考 想法">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="管窥程序">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          一道小小 Python 编程题，体会编程之美
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2021-11-15 23:13:46 / 修改时间：23:40:06" itemprop="dateCreated datePublished" datetime="2021-11-15T23:13:46+08:00">2021-11-15</time>
            </span>

          
            <span id="/2021-11-15-input/" class="post-meta-item leancloud_visitors" data-flag-title="一道小小 Python 编程题，体会编程之美" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021-11-15-input/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021-11-15-input/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>有网友提了一个问题：如何用 Python 实现输入 1~12，返回对应的英文月份简写。</p>
<p>看似简单的一个问题，其中却隐含了关于与用户交互的深层逻辑：</p>
<p>如何更友好？如何更健壮？</p>
<p>那么一起看看如何做到吧。</p>
<a id="more"></a>
<h2 id="条条大路通罗马">条条大路通罗马</h2>
<p>如果就结果而言，解决方法可谓五花八门，可谓条条大路同罗马，而且还有很多 Python 库支撑的方法，比如用 <code>Pendulum</code> 库，可以轻松实现对时间的复杂处理。</p>
<p>之前笔者写了一篇关于 Pendulum 库的介绍 ——<br>
<a href="https://mp.weixin.qq.com/s?__biz=MzkxNDI3NjcwMw==&amp;mid=100012516&amp;idx=1&amp;sn=835c6023933e9ed5a7055d47626566ca&amp;chksm=417259d47605d0c28289a962fe8eaaf5b629cc0905234cdad5a7199cdb58a8e62e2f0fda9498#rd" target="_blank" rel="noopener">跟 “最烦用 Python 处理时间了” 说拜拜</a>，可以参考一下。​</p>
<p>不过，这一道题目，是一个编程练习题，主要是为了训练学习者对Python 代码的熟悉程度，是一个很有意义的练习题目，值得思考和练习。</p>
<h2 id="问题分解">问题分解</h2>
<p>那么如何开始呢？首先需要将这个问题拆解成几个简单部分：</p>
<ol>
<li>为引导用户输入，并对输入内容进行判断；</li>
<li>创建一个英文月份缩写的词典或者列表（主要出于对 Python 基本数据结构的练习考虑，所以不采用标准库或者第三方库的实现方式）</li>
<li>根据用户输入的内容，获得正确的月份缩写，并完成输出</li>
</ol>
<h2 id="处理用户输入">处理用户输入</h2>
<p>对于需要与用户交互的地方，需要考虑到用户的 <strong>输入错误</strong> 的情况。</p>
<p>因为计算机是会严格执行指令的，但人不行，<strong>人擅长的是思考、扩展与创造</strong>，所以我们的程序要尽可能适应用户的输入。</p>
<p>如果站在用户的立场上，这个特性叫人性化。</p>
<p>如何实现呢？直接看代码：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">digit_input</span><span class="params">(msg = <span class="string">"请输入一个数字:"</span>)</span>:</span></span><br><span class="line">  value = input(<span class="string">f"<span class="subst">&#123;msg&#125;</span>\n"</span>)</span><br><span class="line">  <span class="keyword">if</span> value.isdigit():</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>, int(value)</span><br><span class="line">  <span class="keyword">else</span>:</span><br><span class="line">    <span class="keyword">return</span> <span class="number">1</span>, <span class="literal">None</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">'__main__'</span>:</span><br><span class="line">  value = <span class="literal">None</span></span><br><span class="line">  <span class="keyword">while</span> <span class="literal">True</span>:</span><br><span class="line">    code, value = digit_input(<span class="string">"请输入一个 1~12 的整数："</span>)</span><br><span class="line">    <span class="keyword">if</span> code == <span class="number">0</span>:</span><br><span class="line">      <span class="keyword">if</span> value &lt; <span class="number">1</span> <span class="keyword">or</span> value &gt; <span class="number">12</span>:</span><br><span class="line">        print(<span class="string">"您输入的整数小于1或者大于12！"</span>)</span><br><span class="line">      <span class="keyword">else</span>:</span><br><span class="line">        <span class="comment"># 输入正确</span></span><br><span class="line">        <span class="keyword">break</span></span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">      print(<span class="string">"您输入的不是整数！"</span>)</span><br></pre></td></tr></table></figure>
<p>可能会感觉有点晕，我稍作说明。</p>
<ul>
<li>先定义了一个 <code>digit_input</code>  方法，专门用了引导用户输入一个数字，如果输入对了，返回 (0, value) 元组，0 表示输入正确，<code>value</code> 即为用户输入的值（已经转为数值类型了）；如果输入有错，返回 (1, None) ，表示输入有勿，即输入的是非数字</li>
<li>在 <code>main</code> 方法中，有个死循环，如果用户输入不正确的话就会不断地让用户输入，在此先不考虑退出机制，因为用户不想输入直接关闭程序就好了</li>
<li>在循环中，调用 <code>digit_input</code> 方法，获得一个用户的输入，并进行判断，如果是数字，判断是否在 1~12之间，如果不在给出提示，继续循环。如果用户输入的不是数字，直接给出提示，继续循环。只有当用户输入的是数字且在 1~12之间时，才退出循环，而用户输入的值为存放在 <code>value</code> 中。</li>
</ul>
<h2 id="建立月份缩写列表">建立月份缩写列表</h2>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">month_short_name = [<span class="string">''</span>, <span class="string">'Jan'</span>, <span class="string">'Feb'</span>, <span class="string">'Mar'</span>, <span class="string">'Apr'</span>, <span class="string">'May'</span>, <span class="string">'Jun'</span>, <span class="string">'Jul'</span>, <span class="string">'Aug'</span>, <span class="string">'Sep'</span>, <span class="string">'Oct'</span>, <span class="string">'Nov'</span>, <span class="string">'Dec'</span>]</span><br></pre></td></tr></table></figure>
<p>这里也可以用词典代替列表，因为我们要通过输入的数字获得值，利用列表方便一些，因为列表可以看成键值为数字的词典对象。</p>
<p>不过有个问题就是：</p>
<blockquote>
<p>列表的起始索引是0，而我们输入的月份起始是1</p>
</blockquote>
<p>如何对应呢？</p>
<p>采用 <strong>空间换时间</strong> 的方法，将列表的第一个位置存入空值，这样数字就能与列表中的索引对应正确了。</p>
<h2 id="输出">输出</h2>
<p>前面已经获得了用户的正确输入，并有了一个月份列表，这一步就简单了：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">print(month_short_name[value])</span><br></pre></td></tr></table></figure>
<p>直接打印出 <code>value</code> 作为索引 在 <code>month_short_name</code> 中的值就可以了。</p>
<h2 id="集成">集成</h2>
<p>将代码合成起来就是：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">digit_input</span><span class="params">(msg = <span class="string">"请输入一个数字:"</span>)</span>:</span></span><br><span class="line">  value = input(<span class="string">f"<span class="subst">&#123;msg&#125;</span>\n"</span>)</span><br><span class="line">  <span class="keyword">if</span> value.isdigit():</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>, int(value)</span><br><span class="line">  <span class="keyword">else</span>:</span><br><span class="line">    <span class="keyword">return</span> <span class="number">1</span>, <span class="literal">None</span></span><br><span class="line"></span><br><span class="line">month_short_name = [<span class="string">''</span>, <span class="string">'Jan'</span>, <span class="string">'Feb'</span>, <span class="string">'Mar'</span>, <span class="string">'Apr'</span>, <span class="string">'May'</span>, <span class="string">'Jun'</span>, <span class="string">'Jul'</span>, <span class="string">'Aug'</span>, <span class="string">'Sep'</span>, <span class="string">'Oct'</span>, <span class="string">'Nov'</span>, <span class="string">'Dec'</span>]</span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">'__main__'</span>:</span><br><span class="line">  value = <span class="literal">None</span></span><br><span class="line">  <span class="keyword">while</span> <span class="literal">True</span>:</span><br><span class="line">    code, value = digit_input(<span class="string">"请输入一个 1~12 的整数："</span>)</span><br><span class="line">    <span class="keyword">if</span> code == <span class="number">0</span>:</span><br><span class="line">      <span class="keyword">if</span> value &lt; <span class="number">1</span> <span class="keyword">or</span> value &gt; <span class="number">12</span>:</span><br><span class="line">        print(<span class="string">"您输入的整数小于1或者大于12！"</span>)</span><br><span class="line">      <span class="keyword">else</span>:</span><br><span class="line">        <span class="comment"># 输入正确</span></span><br><span class="line">        <span class="keyword">break</span></span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">      print(<span class="string">"您输入的不是整数！"</span>)</span><br><span class="line"></span><br><span class="line">  print(month_short_name[value])</span><br></pre></td></tr></table></figure>
<h2 id="总结">总结</h2>
<p>虽然这道题目很简单，但是它的目标绝不是为了获得正确答案就可以了。</p>
<p>对于编程来说，最重要的是：</p>
<blockquote>
<p><strong>思考方式，是否考虑的周全，是否能替用户多想一步</strong></p>
</blockquote>
<p>很多时候我们在努力帮助用户的同时，其实是在帮助我们自己。</p>
<p>比心！</p>

    </div>

    
    
    

      <footer class="post-footer">

        

			<div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center">
    <img id="wechat_subscriber_qcode" src="/images/wechat-qcode.png" alt="太阳雪 wechat" style="width: 200px; max-width: 100%;"/>
    <div>关注我，获得更多精彩内容</div>
</div>

        
		
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021-09-16-pandoc/" rel="prev" title="神器 Pypandoc —— 实现电子书自由">
      <i class="fa fa-chevron-left"></i> 神器 Pypandoc —— 实现电子书自由
    </a></div>
      <div class="post-nav-item">
    <a href="/2021-11-16-delay/" rel="next" title="一个隐形的拖延症">
      一个隐形的拖延症 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#条条大路通罗马"><span class="nav-number">1.</span> <span class="nav-text">条条大路通罗马</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#问题分解"><span class="nav-number">2.</span> <span class="nav-text">问题分解</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#处理用户输入"><span class="nav-number">3.</span> <span class="nav-text">处理用户输入</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#建立月份缩写列表"><span class="nav-number">4.</span> <span class="nav-text">建立月份缩写列表</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#输出"><span class="nav-number">5.</span> <span class="nav-text">输出</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#集成"><span class="nav-number">6.</span> <span class="nav-text">集成</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#总结"><span class="nav-number">7.</span> <span class="nav-text">总结</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="太阳雪"
      src="/images/avatar.png">
  <p class="site-author-name" itemprop="name">太阳雪</p>
  <div class="site-description" itemprop="description">总结 技术 思考 想法</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">88</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">47</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">太阳雪</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://mist.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Mist</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  
  <script>
    (function(){
      var canonicalURL, curProtocol;
      //Get the <link> tag
      var x=document.getElementsByTagName("link");
		//Find the last canonical URL
		if(x.length > 0){
			for (i=0;i<x.length;i++){
				if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
					canonicalURL=x[i].href;
				}
			}
		}
    //Get protocol
	    if (!canonicalURL){
	    	curProtocol = window.location.protocol.split(':')[0];
	    }
	    else{
	    	curProtocol = canonicalURL.split(':')[0];
	    }
      //Get current URL if the canonical URL does not exist
	    if (!canonicalURL) canonicalURL = window.location.href;
	    //Assign script content. Replace current URL with the canonical URL
      !function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,r=canonicalURL,t=document.referrer;if(!e.test(r)){var n=(String(curProtocol).toLowerCase() === 'https')?"https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif":"//api.share.baidu.com/s.gif";t?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=n}}(window);})();
  </script>















  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'teRj7yeJj0xpfGKLJ5uFdbIu-gzGzoHsz',
      appKey     : '3uie0p1nxouCCnkjiXTEBeLd',
      placeholder: "您的关注是我的动力",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-cn' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
